package com.neusoft.mapper;

import com.neusoft.core.Business;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BusinessMapper {

    @Select("select * from business where orderTypeId=#{orderTypeId} order by businessId")
    public List<Business> listBusinessByOrderTypeId(Integer orderTypeId);

    @Select("select * from business where businessId=#{businessId}")
    public Business getBusinessById(Integer businessId);
    @Select("select * from business where businessName like CONCAT('%', #{keyWord}, '%')")
    public List<Business> listBusinessByKeyWord(String keyWord);

    @Insert("INSERT INTO business (businessName, userId) VALUES (#{businessName}, #{userId})")
    public int saveBusiness(@Param("businessName") String businessName, @Param("userId") String userId);

    @Select("select count(*) from business")
    public Integer getBusinessesNumber();

    @Update("update business set businessName = #{businessName}, businessAddress = #{businessAddress}, businessExplain = #{businessExplain}, orderTypeId = #{orderTypeId}, starPrice = #{starPrice}, deliveryPrice = #{deliveryPrice} where businessId = #{businessId}")
    public int updateBusiness(Business business);

    @Update("update business set businessImg = #{businessImg} where businessId = #{businessId}")
    public int updateBusinessImg(String businessImg, String businessId);
}
